package com.nmsl.controller;

import com.nmsl.common.core.domain.R;
import com.nmsl.service.DepartmentsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/departments")
public class DepartmentsController {
    @Autowired
    private DepartmentsService departmentsService;

    @GetMapping("/selectAllParentDepartments")
    public R selectAllParentDepartments(){
        return R.ok(departmentsService.selectAllParentDepartments());
    }
    @GetMapping("/selectAllChildDepartments")
    public R selectAllChildDepartments(@RequestParam Long id){
        return R.ok(departmentsService.selectAllChildDepartments(id));
    }

    @GetMapping("/getAllChildDepartments")
    public R getAllChildDepartments(){
        return R.ok(departmentsService.getAllChildDepartments());
    }

}
